import Vue from 'vue'
import VueRouter from 'vue-router'
import Recommend from '../views/Recommend'

Vue.use(VueRouter)

// 解决ElementUI导航栏中的vue-router在3.0版本以上重复点菜单报错问题
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

const routes = [
  {
    path: '/',
    name: 'recommend',
    component: Recommend,
  },
  {
    path: '/rankingList',
    name: 'rankingList',
    component: () => import(/* webpackChunkName: "rankingList" */'../views/RankingList.vue')
  },
  {
    path: '/playList',
    name: 'playList',
    component: () => import(/* webpackChunkName: "playList" */'../views/PlayList.vue')
  },
  {
    path: '/station',
    name: 'station',
    component: () => import(/* webpackChunkName: "station" */'../views/DJProgram.vue')
  },
  {
    path: '/singer',
    name: 'singer',
    component: () => import(/* webpackChunkName: "singer" */'../views/Artist.vue')
  },
  {
    path: '/plate',
    name: 'plate',
    component: () => import(/* webpackChunkName: "plate" */'../views/Album.vue')
  },
  // {
  // path: '/about',
  // name: 'about',
  // route level code-splitting
  // this generates a separate chunk (about.[hash].js) for this route
  // which is lazy-loaded when the route is visited.
  // component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
  // }
]

const router = new VueRouter({
  mode: 'hash',
  base: process.env.BASE_URL,
  routes
})

export default router
